var CYJFBridge = {
    
    callbacks : {},

    execute : function(name, parameters, callback) {
        
        if (typeof(name) === 'string') {
            var message = {
                parameters : parameters,
            };
            if (callback) {
                var callbackID = Math.floor(Math.random() * 2000000000);
                this.callbacks[callbackID] = callback;
                message.callbackID = callbackID;
            }
            var _script = 'window.webkit.messageHandlers.' + name + '.postMessage(message);';
            eval(_script);
        } else {
            if (callback) {
                callback(-1, '"name" error.', null);
            }
        }
    },

    callback : function(callbackID, code, msg, result) {
        var callback = this.callbacks[callbackID];
        if (typeof(callback) === 'function') {
            callback(code, msg, result);
        }
        delete this.callbacks[callbackID];
    }
};
